﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="BuscaCep.ascx.cs" Inherits="Voluntariar.WEB.Controls.BuscaCep" %>
<script type="text/javascript" src="/Include/Script/jquery.min.js"></script>
<script type="text/javascript" src="/Include/Script/jquery.maskedinput.js"></script>
<script type="text/javascript">
    j(document).ready(function () {
        j.mask.definitions['~'] = '[-0-9]';
        j('[id$=txtNumero]').mask("?~~~~~~~~~~", { placeholder: "" });

        //        j('[id$=txtNumero]').blur(function () {
        //            if (j('[id$=hdnInicioLimiteNumero]').val() != "" && j('[id$=hdnFinalLimiteNumero]').val() != "" && j('[id$=txtNumero]').val() != "") {
        //                if (parseInt(j('[id$=txtNumero]').val()) > parseInt(j('[id$=hdnInicioLimiteNumero]').val().trim())
        //                        && parseInt(j('[id$=txtNumero]').val()) < parseInt(j('[id$=hdnFinalLimiteNumero]').val().trim())) {

        //                }
        //                else {
        //                    j('[id$=txtNumero]').val('');
        //                    alert("Número esta fora do limite do CEP ! Consulte seu CEP !");
        //                }
        //            }
        //        });
    });
</script>
<asp:Panel ID="pnlBuscaCEP" runat="server" CssClass="caixa_formulario">
    <asp:HiddenField runat="server" ID="hdnInicioLimiteNumero" />
    <asp:HiddenField runat="server" ID="hdnFinalLimiteNumero" />
    <div>
        <fieldset style="width: 200%">
            <legend>Informações de Endereço</legend>
            <p visible="false">
                <asp:Label ID="lblNumeroDocumento" Text="CEP" runat="server" AssociatedControlID="txtCEP" />
                <asp:TextBox ID="txtCEP" runat="server" SkinID="txtGeral" Width="100px" />
                <asp:RequiredFieldValidator ID="rfvCEP" runat="server" ErrorMessage="O campo CEP deve ser preenchido!"
                    ControlToValidate="txtCEP" ForeColor="" CssClass="validacao" ValidationGroup="ucCEP">!</asp:RequiredFieldValidator>
                <asp:LinkButton ID="btnConsultar" runat="server" Text="Consultar" OnClick="btnConsultar_Click"
                    SkinID="lnbPrimario" CausesValidation="true" ValidationGroup="ucCEP" />
            </p>
            <p>
                <asp:Label ID="lblRua" Text="Rua" runat="server" AssociatedControlID="txtRua" />
                <asp:TextBox ID="txtRua" runat="server" SkinID="txtGeral" Width="90%" />
                <asp:RequiredFieldValidator ID="rfvRua" runat="server" ErrorMessage="O campo Rua deve ser preenchido!"
                    ControlToValidate="txtRua" ForeColor="" CssClass="validacao" ValidationGroup="campos">!</asp:RequiredFieldValidator>
            </p>
            <p>
                <asp:Label ID="lblNumero" Text="Numero" runat="server" AssociatedControlID="txtNumero" />
                <asp:TextBox ID="txtNumero" runat="server" SkinID="txtGeral" Width="25%" MaxLength="8" />
                <asp:RequiredFieldValidator ID="rfvNumero" runat="server" ErrorMessage="O campo Numero deve ser preenchido!"
                    ControlToValidate="txtNumero" ForeColor="" CssClass="validacao" ValidationGroup="campos">!</asp:RequiredFieldValidator>
            </p>
            <p>
                <asp:Label ID="lblComplemento" Text="Complemento" runat="server" AssociatedControlID="txtComplemento" />
                <asp:TextBox ID="txtComplemento" runat="server" SkinID="txtGeral" Width="70%" />
            </p>
            <p>
                <asp:Label ID="lblBairro" Text="Bairro" runat="server" AssociatedControlID="txtBairro" />
                <asp:TextBox ID="txtBairro" runat="server" SkinID="txtGeral" Width="70%" />
                <asp:RequiredFieldValidator ID="rfvBairro" runat="server" ErrorMessage="O campo Bairro deve ser preenchido!"
                    ControlToValidate="txtBairro" ForeColor="" CssClass="validacao" ValidationGroup="campos">!</asp:RequiredFieldValidator>
            </p>
            <p>
                <asp:Label ID="lblCidade" Text="Cidade" runat="server" AssociatedControlID="txtCidade" />
                <asp:TextBox ID="txtCidade" runat="server" SkinID="txtGeral" Width="70%" />
                <asp:RequiredFieldValidator ID="rfvCidade" runat="server" ErrorMessage="O campo Cidade deve ser preenchido!"
                    ControlToValidate="txtCidade" ForeColor="" CssClass="validacao" ValidationGroup="campos">!</asp:RequiredFieldValidator>
            </p>
            <p>
                <asp:Label ID="lblEstado" Text="Estado" runat="server" AssociatedControlID="txtEstado" />
                <asp:TextBox ID="txtEstado" runat="server" SkinID="txtGeral" Width="15%" MaxLength="2" />
                <asp:RequiredFieldValidator ID="rfvEstado" runat="server" ErrorMessage="O campo Estado deve ser preenchido!"
                    ControlToValidate="txtEstado" ForeColor="" CssClass="validacao" ValidationGroup="campos">!</asp:RequiredFieldValidator>
            </p>
        </fieldset>
    </div>
    <div class="linha_botoes">
        <asp:LinkButton runat="server" ID="lnbSalvar" OnClick="lnbSalvar_OnClick" SkinID="lnbPrimario"
            CausesValidation="true" ValidationGroup="campos">Salvar</asp:LinkButton>
        <asp:LinkButton runat="server" ID="lnbLimpar" OnClick="lnbLimpar_OnClick" SkinID="lnbPrimario"
            CausesValidation="false">Limpar</asp:LinkButton>
    </div>
    <script type="text/javascript">
        var g = jQuery.noConflict();
        g(document).ready(function () {
            g('[id$=txtCEP]').mask("99.999-999");
        });
    </script>
    <asp:ValidationSummary ID="vlsUcCEP" runat="server" ShowMessageBox="True" ShowSummary="False"
        ValidationGroup="ucCEP" />
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
        ShowSummary="False" ValidationGroup="campos" />
</asp:Panel>
